#!/bin/bash

# 检查 sudo 是否已安装
if ! command -v sudo > /dev/null; then
    echo "正在安装 sudo..."
    apt-get install sudo -y
else
    echo "sudo 已安装，正在升级..."
    apt-get upgrade sudo -y
fi

# 检查 Sublime Text 是否已安装
if dpkg -l | grep sublime-text > /dev/null; then
    echo "Sublime Text 已安装，正在升级..."
    sudo apt-get upgrade sublime-text -y
else
    echo "正在安装 Sublime Text..."
    sudo apt-get install apt-transport-https -y
    wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/sublimehq-archive.gpg > /dev/null
    echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
    sudo apt-get update
    sudo apt-get install sublime-text -y
fi

# 检查 Firefox 是否已安装
if dpkg -l | grep firefox > /dev/null; then
    echo "Firefox 已安装，正在升级..."
    sudo apt-get upgrade firefox -y
else
    echo "正在安装 Firefox..."
    sudo apt-get install firefox -y
fi

echo "操作完成。"